package com.xiangban.controller;

import com.xiangban.aop.Permission;
import com.xiangban.model.Hospital;
import com.xiangban.model.res.ApiResult;
import com.xiangban.model.res.Ids;
import com.xiangban.service.HospitalService;
import com.xiangban.service.impl.HospitalServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/12/1 9:36
 */
@RestController
@RequestMapping("/hospital")
@Api(tags = "陪诊医院基本信息")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    @RequestMapping("/saveHospital")
    @ApiOperation("添加医院")
    @Permission(permission = "admin:hospital:saveHospital")
    //master、slave
    public ApiResult<Object> saveHospital(@RequestBody Hospital hospital){
        hospitalService.saveHospital(hospital);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/removeHospital")
    @ApiOperation("删除(下线)医院")
    @Permission(permission = "admin:hospital:removeHospital")
    //master
    //可批量删除或者下线医院
    public ApiResult<Object> removeHospital(@RequestBody Ids ids){
        hospitalService.removeHospital(ids);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/updateHospital")
    @ApiOperation("修改医院信息")
    @Permission(permission = "admin:hospital:updateHospital")
    //master、slave
    public ApiResult<Object> updateHospital(@RequestBody Hospital hospital){
        hospitalService.updateHospital(hospital);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/getHospital")
    @ApiOperation("详情医院信息")
    @Permission(permission = "admin:hospital:getHospital")
    //master、slave
    public ApiResult<Object> getHospital(@RequestBody Hospital hospital){
        return ApiResult.newSuccess(hospitalService.getHospital(hospital));
    }

    @RequestMapping("/listHospitalPage")
    @ApiOperation("获取医院列表")
    @Permission(permission = "admin:hospital:listHospitalPage")
    //master、slave
    public ApiResult<Object> listHospitalPage(@RequestBody Hospital hospital){
        return ApiResult.newSuccess(hospitalService.listHospitalPage(hospital));
    }

}
